#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
const int maxn = 120000;
int a[maxn]={0};
int main()
{
	int n,id=1,max=-1;
	scanf("%d",&n);
	
	for(int i=0;i<n;i++){
		int Schid,num;
		scanf("%d %d",&Schid,&num);
		a[Schid]+=num;
			if(a[Schid]>max){
				max=a[Schid];
				id=Schid;
			}		
	}
	printf("%d %d\n",id,max);
	return 0; 
}
